package com.chenshu.shop.config;

import com.chenshu.shop.service.TypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.HandlerInterceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * Created with IntelliJ IDEA
 * Description
 * User：chenshu
 * Date：2024-06-12
 * Time：10:24
 */
@Component
public class TypeListInterceptor implements HandlerInterceptor {
    @Autowired
    TypeService typeService;
    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
        request.setAttribute("typeList", typeService.getAllTypes());
        return true;
    }
}
